home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 49
/
Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso
/
-serious-
/
misc
/
db3.6-beta
/
db3.6-beta-src
/
designgui.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-11-30
|
31KB
|
853 lines
/*
* Source machine generated by GadToolsBox V2.0b
* which is (c) Copyright 1991-1993 Jaba Development
*
* GUI Designed by : David Ekholm, Datadosen
*/
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/imageclass.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/utility_protos.h>
#include <string.h>
#include <pragmas/exec_pragmas.h>
#include <pragmas/intuition_pragmas.h>
#include <pragmas/gadtools_pragmas.h>
#include <pragmas/graphics_pragmas.h>
#include <pragmas/utility_pragmas.h>
#include "DesignGUI.h"
#include "DesignGUI_fix.h"
#define CATCOMP_NUMBERS
#include "db.h"
/*
static struct Window *MainWnd = NULL;
static struct Window *TagWnd = NULL;
static struct Window *NameWnd = NULL;
static struct Window *FieldWnd = NULL;
*/
struct Window *VisWnd = NULL;
/*
static struct Gadget *MainGList = NULL;
static struct Gadget *TagGList = NULL;
static struct Gadget *NameGList = NULL;
static struct Gadget *FieldGList = NULL;
*/
static struct Gadget *VisGList = NULL;
struct Menu *DesignMenus = NULL;
/*
struct IntuiMessage MainMsg;
struct IntuiMessage TagMsg;
struct IntuiMessage NameMsg;
struct IntuiMessage FieldMsg;
*/
struct IntuiMessage VisMsg;
/*
static struct Gadget *MainGadgets[11];
static struct Gadget *TagGadgets[4];
static struct Gadget *NameGadgets[3];
static struct Gadget *FieldGadgets[5];
*/
struct Gadget *VisGadgets[8];
/*
static UWORD MainLeft = 227;
static UWORD MainTop = 186;
static UWORD MainWidth = 305;
static UWORD MainHeight = 182;
static UWORD TagLeft = 89;
static UWORD TagTop = 162;
static UWORD TagWidth = 489;
static UWORD TagHeight = 63;
static UWORD NameLeft = 237;
static UWORD NameTop = 199;
static UWORD NameWidth = 283;
static UWORD NameHeight = 64;
static UWORD FieldLeft = 149;
static UWORD FieldTop = 218;
static UWORD FieldWidth = 329;
static UWORD FieldHeight = 102;
*/
static UWORD VisLeft = 150;
static UWORD VisTop = 174;
static UWORD VisWidth = 398;
static UWORD VisHeight = 122;
/*
static UBYTE *MainWdt = (UBYTE *)"List Window";
static UBYTE *TagWdt = (UBYTE *)"Edit tag";
static UBYTE *NameWdt = (UBYTE *)"Edit name";
static UBYTE *FieldWdt = (UBYTE *)"Edit field object";
static UBYTE *VisWdt = (UBYTE *)"Edit visual field object";
*/
static struct TextAttr *Font, Attr;
static UWORD FontX, FontY;
static UWORD OffX, OffY;
struct NewMenu DesignNewMenu[] = {
NM_TITLE,(STRPTR)MSG_PROJECT_MENU , NULL, 0, NULL, NULL,
NM_ITEM, (STRPTR)MSG_EDVIEW_ABOUT , NULL, 0, 0L , (APTR)DesignPROJECT_ABOUT,
NM_ITEM, (STRPTR)MSG_EDVIEW_EXIT , NULL, 0, 0L , (APTR)DesignPROJECT_EXIT,
NM_TITLE,(STRPTR)MSG_EDVIEW_EDIT , NULL, 0, NULL, NULL,
NM_ITEM, (STRPTR)MSG_EDVIEW_UNDO , NULL, NM_ITEMDISABLED, 0L, (APTR)DesignEDIT_UNDO,
NM_ITEM, (STRPTR)NM_BARLABEL, NULL ,0, 0L, NULL,
NM_ITEM, (STRPTR)MSG_EDVIEW_CUT , NULL, 0, 0L, (APTR)DesignEDIT_CUT,
NM_ITEM, (STRPTR)MSG_EDVIEW_COPY , NULL, 0, 0L, (APTR)DesignEDIT_COPY,
NM_ITEM, (STRPTR)MSG_EDVIEW_PASTE , NULL, NM_ITEMDISABLED, 0L, (APTR)DesignEDIT_PASTE,
NM_END, NULL, NULL, 0, 0L, NULL };
/*
static UWORD MainGTypes[] = {
LISTVIEW_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND
};
static UWORD TagGTypes[] = {
STRING_KIND,
STRING_KIND,
BUTTON_KIND,
BUTTON_KIND
};
static UWORD NameGTypes[] = {
STRING_KIND,
BUTTON_KIND,
BUTTON_KIND
};
static UWORD FieldGTypes[] = {
STRING_KIND,
INTEGER_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND
};
*/
static UWORD VisGTypes[] = {
STRING_KIND, // Name
INTEGER_KIND, // size
BUTTON_KIND, // ok
BUTTON_KIND, // cancel
BUTTON_KIND, // more
TEXT_KIND, // field
BUTTON_KIND, // select
CYCLE_KIND // type
};
/*
static struct NewGadget MainNGad[] = {
4, 20, 221, 117, (UBYTE *)"Object list", NULL, GD_LIST, PLACETEXT_ABOVE, NULL, (APTR)LISTClicked,
232, 20, 69, 17, (UBYTE *)"Top", NULL, GD_TOP, PLACETEXT_IN, NULL, (APTR)TOPClicked,
232, 44, 69, 17, (UBYTE *)"Up", NULL, GD_UP, PLACETEXT_IN, NULL, (APTR)UPClicked,
232, 68, 69, 17, (UBYTE *)"Down", NULL, GD_DOWN, PLACETEXT_IN, NULL, (APTR)DOWNClicked,
232, 92, 69, 17, (UBYTE *)"Bottom", NULL, GD_BOTTOM, PLACETEXT_IN, NULL, (APTR)BOTTOMClicked,
4, 136, 69, 17, (UBYTE *)"_New...", NULL, GD_NEW, PLACETEXT_IN, NULL, (APTR)NEWClicked,
80, 136, 69, 17, (UBYTE *)"_Edit...", NULL, GD_EDIT, PLACETEXT_IN, NULL, (APTR)EDITClicked,
156, 136, 69, 17, (UBYTE *)"Co_py", NULL, GD_COPY, PLACETEXT_IN, NULL, (APTR)COPYClicked,
232, 136, 69, 17, (UBYTE *)"Remove", NULL, GD_REMOVE, PLACETEXT_IN, NULL, (APTR)REMOVEClicked,
4, 160, 69, 17, (UBYTE *)"_Use", NULL, GD_USE, PLACETEXT_IN, NULL, (APTR)USEClicked,
232, 160, 69, 17, (UBYTE *)"_Cancel", NULL, GD_CANCEL, PLACETEXT_IN, NULL, (APTR)CANCELClicked
};
static struct NewGadget TagNGad[] = {
190, 6, 292, 21, (UBYTE *)"_Value", NULL, GD_TAG_VALUE, PLACETEXT_LEFT, NULL, (APTR)TAG_VALUEClicked,
30, 6, 101, 21, (UBYTE *)"_ID", NULL, GD_TAG_ID, PLACETEXT_LEFT, NULL, (APTR)TAG_IDClicked,
6, 42, 61, 17, (UBYTE *)"_Ok", NULL, GD_TAG_OK, PLACETEXT_IN, NULL, (APTR)TAG_OKClicked,
422, 42, 61, 17, (UBYTE *)"_Cancel", NULL, GD_TAG_CANCEL, PLACETEXT_IN, NULL, (APTR)TAG_CANCELClicked
};
static struct NewGadget NameNGad[] = {
52, 6, 225, 21, (UBYTE *)"_Name", NULL, GD_NAME_NAME, PLACETEXT_LEFT, NULL, (APTR)NAME_NAMEClicked,
6, 42, 61, 17, (UBYTE *)"_Ok", NULL, GD_NAME_OK, PLACETEXT_IN, NULL, (APTR)NAME_OKClicked,
215, 42, 61, 17, (UBYTE *)"_Cancel", NULL, GD_NAME_CANCEL, PLACETEXT_IN, NULL, (APTR)NAME_CANCELClicked
};
static struct NewGadget FieldNGad[] = {
64, 8, 113, 21, (UBYTE *)"_Name", NULL, GD_FIELD_NAME, PLACETEXT_LEFT, NULL, (APTR)FIELD_NAMEClicked,
264, 8, 57, 21, (UBYTE *)"Max _length", NULL, GD_FIELD_MAXLEN, PLACETEXT_LEFT, NULL, (APTR)FIELD_MAXLENClicked,
4, 80, 69, 17, (UBYTE *)"_Ok", NULL, GD_FIELD_OK, PLACETEXT_IN, NULL, (APTR)FIELD_OKClicked,
256, 80, 69, 17, (UBYTE *)"_Cancel", NULL, GD_FIELD_CANCEL, PLACETEXT_IN, NULL, (APTR)FIELD_CANCELClicked,
128, 80, 69, 17, (UBYTE *)"_More...", NULL, GD_FIELD_MORE, PLACETEXT_IN, NULL, (APTR)FIELD_MOREClicked
};
*/
static char *GadgetType_Labels[] = {
(char *)"String",
(char *)"Text",
(char *)"Textfield",
(char *)"Cycle",
(char *)"Checkbox",
NULL
};
static struct NewGadget VisNGad[] = {
72, 8, 205, 21, (UBYTE *)"_Name" , NULL, GD_VIS_NAME , PLACETEXT_LEFT, NULL, (APTR)VIS_NAMEClicked,
348, 8, 46, 21, (UBYTE *)"Si_ze" , NULL, GD_VIS_SIZE , PLACETEXT_LEFT, NULL, (APTR)VIS_SIZEClicked,
4, 100, 79, 17, (UBYTE *)"_Ok" , NULL, GD_VIS_OK , PLACETEXT_IN , NULL, (APTR)VIS_OKClicked,
315, 100, 78, 17, (UBYTE *)"_Cancel" , NULL, GD_VIS_CANCEL, PLACETEXT_IN , NULL, (APTR)VIS_CANCELClicked,
160, 100, 89, 17, (UBYTE *)"_More..." , NULL, GD_VIS_MORE , PLACETEXT_IN , NULL, (APTR)VIS_MOREClicked,
72, 36, 123, 21, (UBYTE *)"Field" , NULL, GD_VIS_FIELD , PLACETEXT_LEFT, NULL, NULL,
205, 40, 75, 17, (UBYTE *)"Select...", NULL, GD_VIS_SELECT, PLACETEXT_IN , NULL, (APTR)VIS_SELECTClicked,
72, 64, 322, 21, (UBYTE *)"_Type" , NULL, GD_VIS_TYPE , PLACETEXT_IN , NULL, NULL
};
/*
static ULONG MainGTags[] = {
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE)
};
static ULONG TagGTags[] = {
(GTST_MaxChars), 256, (GT_Underscore), '_', (TAG_DONE),
(GTST_MaxChars), 45, (GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE)
};
static ULONG NameGTags[] = {
(GTST_MaxChars), 45, (GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE)
};
static ULONG FieldGTags[] = {
(GTST_MaxChars), 45, (GT_Underscore), '_', (TAG_DONE),
(GTIN_Number), 200, (GTIN_MaxChars), 5, (GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE)
};
*/
static ULONG VisGTags[] = {
(GTST_MaxChars), 45 , (GT_Underscore), '_', (TAG_DONE),
(GTIN_Number) , 25 , (GTIN_MaxChars), 3, (GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_' , (TAG_DONE),
(GT_Underscore), '_' , (TAG_DONE),
(GT_Underscore), '_' , (GA_Disabled), TRUE, (TAG_DONE),
(GTTX_Border) , TRUE, (TAG_DONE),
(GT_Underscore), '_' , (TAG_DONE),
(GT_Underscore), '_' , GTCY_Active, 0, GTCY_Labels, &GadgetType_Labels, (TAG_DONE)
};
static UWORD ComputeX( UWORD value )
{
return(( UWORD )((( FontX * value ) + 4 ) / 8 ));
}
static UWORD ComputeY( UWORD value )
{
return(( UWORD )((( FontY * value ) + 6 ) / 13 ));
}
static void ComputeFont( UWORD width, UWORD height )
{
Font = &Attr;
Font->ta_Name = (STRPTR)Scr->RastPort.Font->tf_Message.mn_Node.ln_Name;
Font->ta_YSize = FontY = Scr->RastPort.Font->tf_YSize;
FontX = Scr->RastPort.Font->tf_XSize;
OffX = Scr->WBorLeft;
OffY = Scr->RastPort.TxHeight + Scr->WBorTop + 1;
if ( width && height ) {
if (( ComputeX( width ) + OffX + Scr->WBorRight ) > Scr->Width )
goto UseTopaz;
if (( ComputeY( height ) + OffY + Scr->WBorBottom ) > Scr->Height )
goto UseTopaz;
}
return;
UseTopaz:
Font->ta_Name = (STRPTR)"topaz.font";
FontX = FontY = Font->ta_YSize = 8;
}
/// Old parts
/*
int HandleMainIDCMP( void )
{
struct IntuiMessage *m;
int (*func)();
BOOL running = TRUE;
while( m = GT_GetIMsg( MainWnd->UserPort )) {
CopyMem(( char * )m, ( char * )&MainMsg, (long)sizeof( struct IntuiMessage ));
GT_ReplyIMsg( m );
switch ( MainMsg.Class ) {
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh( MainWnd );
GT_EndRefresh( MainWnd, TRUE );
break;
case IDCMP_CLOSEWINDOW:
running = MainCloseWindow();
break;
case IDCMP_VANILLAKEY:
running = MainVanillaKey();
break;
case IDCMP_RAWKEY:
running = MainRawKey();
break;
case IDCMP_GADGETUP:
case IDCMP_GADGETDOWN:
func = ( void * )(( struct Gadget * )MainMsg.IAddress )->UserData;
running = func();
break;
}
}
return( running );
}
int OpenMainWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD wleft = MainLeft, wtop = MainTop, ww, wh;
ComputeFont( MainWidth, MainHeight );
ww = ComputeX( MainWidth );
wh = ComputeY( MainHeight );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( g = CreateContext( &MainGList )))
return( 1L );
for( lc = 0, tc = 0; lc < Main_CNT; lc++ ) {
CopyMem((char * )&MainNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = Font;
ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
ng.ng_Width = ComputeX( ng.ng_Width );
ng.ng_Height = ComputeY( ng.ng_Height);
MainGadgets[ lc ] = g = CreateGadgetA((ULONG)MainGTypes[ lc ], g, &ng, ( struct TagItem * )&MainGTags[ tc ] );
while( MainGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
if ( ! ( MainWnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, LISTVIEWIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_RAWKEY|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE|WFLG_RMBTRAP,
WA_Gadgets, MainGList,
WA_Title, MainWdt,
WA_PubScreen, Scr,
TAG_DONE )))
return( 4L );
GT_RefreshWindow( MainWnd, NULL );
return( 0L );
}
void CloseMainWindow( void )
{
if ( MainWnd ) {
CloseWindow( MainWnd );
MainWnd = NULL;
}
if ( MainGList ) {
FreeGadgets( MainGList );
MainGList = NULL;
}
}
int HandleTagIDCMP( void )
{
struct IntuiMessage *m;
int (*func)();
BOOL running = TRUE;
while( m = GT_GetIMsg( TagWnd->UserPort )) {
CopyMem(( char * )m, ( char * )&TagMsg, (long)sizeof( struct IntuiMessage ));
GT_ReplyIMsg( m );
switch ( TagMsg.Class ) {
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh( TagWnd );
GT_EndRefresh( TagWnd, TRUE );
break;
case IDCMP_CLOSEWINDOW:
running = TagCloseWindow();
break;
case IDCMP_VANILLAKEY:
running = TagVanillaKey();
break;
case IDCMP_GADGETUP:
func = ( void * )(( struct Gadget * )TagMsg.IAddress )->UserData;
running = func();
break;
}
}
return( running );
}
int OpenTagWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD wleft = TagLeft, wtop = TagTop, ww, wh;
ComputeFont( TagWidth, TagHeight );
ww = ComputeX( TagWidth );
wh = ComputeY( TagHeight );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( g = CreateContext( &TagGList )))
return( 1L );
for( lc = 0, tc = 0; lc < Tag_CNT; lc++ ) {
CopyMem((char * )&TagNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = Font;
ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
ng.ng_Width = ComputeX( ng.ng_Width );
ng.ng_Height = ComputeY( ng.ng_Height);
TagGadgets[ lc ] = g = CreateGadgetA((ULONG)TagGTypes[ lc ], g, &ng, ( struct TagItem * )&TagGTags[ tc ] );
while( TagGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
if ( ! ( TagWnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, STRINGIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
WA_Gadgets, TagGList,
WA_Title, TagWdt,
WA_PubScreen, Scr,
TAG_DONE )))
return( 4L );
GT_RefreshWindow( TagWnd, NULL );
return( 0L );
}
void CloseTagWindow( void )
{
if ( TagWnd ) {
CloseWindow( TagWnd );
TagWnd = NULL;
}
if ( TagGList ) {
FreeGadgets( TagGList );
TagGList = NULL;
}
}
int HandleNameIDCMP( void )
{
struct IntuiMessage *m;
int (*func)();
BOOL running = TRUE;
while( m = GT_GetIMsg( NameWnd->UserPort )) {
CopyMem(( char * )m, ( char * )&NameMsg, (long)sizeof( struct IntuiMessage ));
GT_ReplyIMsg( m );
switch ( NameMsg.Class ) {
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh( NameWnd );
GT_EndRefresh( NameWnd, TRUE );
break;
case IDCMP_CLOSEWINDOW:
running = NameCloseWindow();
break;
case IDCMP_VANILLAKEY:
running = NameVanillaKey();
break;
case IDCMP_GADGETUP:
func = ( void * )(( struct Gadget * )NameMsg.IAddress )->UserData;
running = func();
break;
}
}
return( running );
}
int OpenNameWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD wleft = NameLeft, wtop = NameTop, ww, wh;
ComputeFont( NameWidth, NameHeight );
ww = ComputeX( NameWidth );
wh = ComputeY( NameHeight );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( g = CreateContext( &NameGList )))
return( 1L );
for( lc = 0, tc = 0; lc < Name_CNT; lc++ ) {
CopyMem((char * )&NameNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = Font;
ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
ng.ng_Width = ComputeX( ng.ng_Width );
ng.ng_Height = ComputeY( ng.ng_Height);
NameGadgets[ lc ] = g = CreateGadgetA((ULONG)NameGTypes[ lc ], g, &ng, ( struct TagItem * )&NameGTags[ tc ] );
while( NameGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
if ( ! ( NameWnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, STRINGIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
WA_Gadgets, NameGList,
WA_Title, NameWdt,
WA_PubScreen, Scr,
TAG_DONE )))
return( 4L );
GT_RefreshWindow( NameWnd, NULL );
return( 0L );
}
void CloseNameWindow( void )
{
if ( NameWnd ) {
CloseWindow( NameWnd );
NameWnd = NULL;
}
if ( NameGList ) {
FreeGadgets( NameGList );
NameGList = NULL;
}
}
int HandleFieldIDCMP( void )
{
struct IntuiMessage *m;
int (*func)();
BOOL running = TRUE;
while( m = GT_GetIMsg( FieldWnd->UserPort )) {
CopyMem(( char * )m, ( char * )&FieldMsg, (long)sizeof( struct IntuiMessage ));
GT_ReplyIMsg( m );
switch ( FieldMsg.Class ) {
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh( FieldWnd );
GT_EndRefresh( FieldWnd, TRUE );
break;
case IDCMP_CLOSEWINDOW:
running = FieldCloseWindow();
break;
case IDCMP_VANILLAKEY:
running = FieldVanillaKey();
break;
case IDCMP_GADGETUP:
func = ( void * )(( struct Gadget * )FieldMsg.IAddress )->UserData;
running = func();
break;
}
}
return( running );
}
int OpenFieldWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD wleft = FieldLeft, wtop = FieldTop, ww, wh;
ComputeFont( FieldWidth, FieldHeight );
ww = ComputeX( FieldWidth );
wh = ComputeY( FieldHeight );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( g = CreateContext( &FieldGList )))
return( 1L );
for( lc = 0, tc = 0; lc < Field_CNT; lc++ ) {
CopyMem((char * )&FieldNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = Font;
ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
ng.ng_Width = ComputeX( ng.ng_Width );
ng.ng_Height = ComputeY( ng.ng_Height);
FieldGadgets[ lc ] = g = CreateGadgetA((ULONG)FieldGTypes[ lc ], g, &ng, ( struct TagItem * )&FieldGTags[ tc ] );
while( FieldGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
if ( ! ( FieldWnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, STRINGIDCMP|INTEGERIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
WA_Gadgets, FieldGList,
WA_Title, FieldWdt,
WA_PubScreen, Scr,
TAG_DONE )))
return( 4L );
GT_RefreshWindow( FieldWnd, NULL );
return( 0L );
}
void CloseFieldWindow( void )
{
if ( FieldWnd ) {
CloseWindow( FieldWnd );
FieldWnd = NULL;
}
if ( FieldGList ) {
FreeGadgets( FieldGList );
FieldGList = NULL;
}
}
*/
//|
int HandleVisIDCMP( void )
{
struct IntuiMessage *m;
int (*func)();
BOOL running = TRUE;
while( m = GT_GetIMsg( VisWnd->UserPort )) {
CopyMem(( char * )m, ( char * )&VisMsg, (long)sizeof( struct IntuiMessage ));
GT_ReplyIMsg( m );
switch ( VisMsg.Class ) {
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh( VisWnd );
GT_EndRefresh( VisWnd, TRUE );
break;
case IDCMP_CLOSEWINDOW:
running = VisCloseWindow();
break;
case IDCMP_VANILLAKEY:
running = VisVanillaKey();
break;
case IDCMP_GADGETUP:
func = ( void * )(( struct Gadget * )VisMsg.IAddress )->UserData;
if(func)
running = func();
else
running = 0;
break;
}
}
return( running );
}
/*
** Edit item window
*/
int OpenVisWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD wleft = VisLeft, wtop = VisTop, ww, wh;
char i;
/* Localization. Poor but works ;-) */
VisNGad[0].ng_GadgetText = GetAppStr(MSG_EDVIEW_EDIT_NAME);
VisNGad[1].ng_GadgetText = GetAppStr(MSG_EDVIEW_EDIT_SIZE);
VisNGad[2].ng_GadgetText = GetAppStr(MSG_EDVIEW_EDIT_OK);
VisNGad[3].ng_GadgetText = GetAppStr(MSG_EDVIEW_EDIT_CANCEL);
VisNGad[4].ng_GadgetText = GetAppStr(MSG_EDVIEW_EDIT_MORE);
VisNGad[5].ng_GadgetText = GetAppStr(MSG_EDVIEW_EDIT_FIELD);
VisNGad[6].ng_GadgetText = GetAppStr(MSG_EDVIEW_EDIT_SELECT);
VisNGad[7].ng_GadgetText = GetAppStr(MSG_EDVIEW_EDIT_TYPE);
for(i=0; i<5; i++)
GadgetType_Labels[i] = (char *)GetAppStr(MSG_EDVIEW_TYPE_0 + i);
ComputeFont( VisWidth, VisHeight );
ww = ComputeX( VisWidth );
wh = ComputeY( VisHeight );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( g = CreateContext( &VisGList )))
return( 1L );
for( lc = 0, tc = 0; lc < Vis_CNT; lc++ ) {
CopyMem((char * )&VisNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = Font;
ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
ng.ng_Width = ComputeX( ng.ng_Width );
ng.ng_Height = ComputeY( ng.ng_Height);
VisGadgets[ lc ] = g = CreateGadgetA((ULONG)VisGTypes[ lc ], g, &ng, ( struct TagItem * )&VisGTags[ tc ] );
while( VisGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
if ( ! ( VisWnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, STRINGIDCMP|INTEGERIDCMP|BUTTONIDCMP|TEXTIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
WA_Gadgets, VisGList,
WA_Title, GetAppStr(MSG_EDVIEW_TITLE),
WA_PubScreen, Scr,
TAG_DONE )))
return( 4L );
GT_RefreshWindow( VisWnd, NULL );
return( 0L );
}
void CloseVisWindow( void )
{
if ( VisWnd ) {
CloseWindow( VisWnd );
VisWnd = NULL;
}
if ( VisGList ) {
FreeGadgets( VisGList );
VisGList = NULL;
}
}